<template>
  <view class="info-box">
    <!-- 头像昵称区域 -->
    <view class="header">
      <image class="img" :src="userInfo.avatarUrl"></image>
      <text>{{ userInfo.nickName }}</text>
    </view>
    <view class="panel-list">
      <!-- 第一个面板 -->
      <view class="panel">
        <view class="panel-item">
          <text>8</text>
          <text>收藏的店铺</text>
        </view>
        <view class="panel-item">
          <text>14</text>
          <text>收藏的商品</text>
        </view>
        <view class="panel-item">
          <text>18</text>
          <text>关注的商品</text>
        </view>
        <view class="panel-item">
          <text>84</text>
          <text>足迹</text>
        </view>
      </view>
      <!-- 第二个面板 -->
      <view class="panel1">
        <view class="panel1-title"><text>我的订单</text></view>
        <view class="item-box">
          <view class="panel1-item">
            <image src="../../static/my-icons/icon1.png" mode=""></image>
            <text>待付款</text>
          </view>
          <view class="panel1-item">
            <image src="../../static/my-icons/icon2.png" mode=""></image>
            <text>待付款</text>
          </view>
          <view class="panel1-item">
            <image src="../../static/my-icons/icon3.png" mode=""></image>
            <text>待付款</text>
          </view>
          <view class="panel1-item">
            <image src="../../static/my-icons/icon4.png" mode=""></image>
            <text>待付款</text>
          </view>
        </view>
      </view>
      <!-- 第三个面板 -->
      <view class="panel2">
        <view class="panel2-item">
          <text>收货地址</text>
          <uni-icons type="arrowright" size="15"></uni-icons>
        </view>
        <view class="panel2-item">
          <text>联系客服</text>
          <uni-icons type="arrowright" size="15"></uni-icons>
        </view>
        <view class="panel2-item" @click="logout">
          <text>退出登录</text>
          <uni-icons type="arrowright" size="15"></uni-icons>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState('myAddress', ['userInfo'])
  },
  methods: {
    ...mapMutations('myAddress', ['updataAddress', 'updataUserInfo', 'saveToken']),
    async logout() {
      const [err, res] = await uni.showModal({
        title: '提示',
        content: '确认退出登录?'
      });
      console.log(res);
      if (res&&res.confirm) {
        this.updataAddress({});
        this.updataUserInfo({});
        this.saveToken('');
      }
      else {
        uni.$showMsg('退出登录失败!')
      }
    },
  }
};
</script>

<style lang="scss">
.info-box {
  height: 100%;
  background-color: #f4f4f4;
  .header {
    height: 400rpx;
    background-color: #c00000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    .img {
      height: 180rpx;
      width: 180rpx;
      border-radius: 50%;
      background-color: skyblue;
      border: 2px solid #fff;
      box-shadow: 0 0 5px 2px #000000;
      margin-bottom: 20rpx;
    }
  }
}

.panel-list {
  padding: 0 20rpx;
  .panel {
    display: flex;
    justify-content: space-around;
    background-color: #ffffff;
    width: 100%;
    position: relative;
    top: -20rpx;
    .panel-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 28rpx;
      padding: 15rpx 0;
    }
  }
  .panel1 {
    background-color: #ffffff;
    .panel1-title {
      padding: 20rpx 15rpx 15rpx;
      font-size: 26rpx;
    }
    .item-box {
      display: flex;
      justify-content: space-around;

      width: 100%;
      .panel1-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 28rpx;
        padding: 15rpx 0;
        image {
          width: 70rpx;
          height: 70rpx;
        }
      }
    }
  }
  .panel2 {
    margin-top: 20rpx;
    background-color: #fff;
    .panel2-item {
      display: flex;
      justify-content: space-between;
      padding: 20rpx;
      font-size: 28rpx;
    }
  }
}
</style>
